import { AlertProps } from '@mui/material'
import * as actionTypes from './actions'

export type GlobalState = {
  snackbar: Pick<AlertProps, 'children' | 'severity'> | null
}
const initialState = {
  snackbar: null
}

interface Action {
  type: string
  payload?: any
}

const globalReducer = (state = initialState, action: Action) => {
  switch (action.type) {
    case actionTypes.SET_SNACKBAR:
      return {
        ...state,
        snackbar: action.payload
      }
    default:
      return state
  }
}

export default globalReducer
